"""
进度 PO
"""

import utils.enum_utils as enum
from models import POBase
from models.other import ProcessHistory
from utils.data_utils.special import ObjectIdStr
from utils.validator_utils.pydantic_validator.field import (
    CharField,
    IntegerField,
    ListField,
    NormalField,
)


class ProcessPO(POBase):
    """ 进度 | PO """

    exception_msg: str = CharField("", title="异常信息", max_length=1024)
    history: list[ProcessHistory] = ListField(default_factory=list, title="历史记录")
    percent: int = IntegerField(0, title="进度百分比", min_value=0, max_value=100)
    result: dict = NormalField(default_factory=dict, title="结果")
    status: enum.ProcessStatus = CharField(enum.ProcessStatus.INITIAL, title="任务状态")
    task: enum.ProcessTask = CharField(..., title="任务编号")
    user_id: ObjectIdStr = NormalField(..., title="用户 ID")
